package org.upo.eps.it.phama.struts.actionform;

import java.security.NoSuchAlgorithmException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.upo.eps.it.phama.bean.Empleado;
import org.upo.eps.it.phama.dao.EmpleadoDAO;
import org.upo.eps.it.phama.util.Utils;

/**
 *
 * @author grupo 4
 */
public class LoginActionForm extends ActionForm {

    private String user;
    private String password;
    private ActionErrors errors;

    //<editor-fold defaultstate="collapsed" desc="constructors">
    public LoginActionForm() {
        super();
    }
    //</editor-fold>
    //<editor-fold defaultstate="collapsed" desc="getters & setters">

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
    //</editor-fold>

    /**
     * This is the action called from the Struts framework.
     *
     * @param mapping The ActionMapping used to select this instance.
     * @param request The HTTP Request we are processing.
     * @return
     */
    @Override
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        errors = new ActionErrors();
        if (getUser() != null && getUser().length() < 1) {
            errors.add("usuario", new ActionMessage("error.required", "usuario"));
        }
        if (getPassword() != null && getPassword().length() < 1) {
            errors.add("contrase&ntilde;a", new ActionMessage("error.required", "contrase&ntilde;a"));
        }

        return errors;
    }
    
    public ActionErrors getErrors(){
        return this.errors;
    }
}
